package com.ch.doudemo.view;

import android.content.Context;
import android.view.LayoutInflater;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.ch.doudemo.R;
import com.ch.doudemo.activity.SingleVideoActivity;
import com.ch.doudemo.bean.VideoDetailResBean;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by ColorRain on 2018/4/17.
 */

public class SVideoCommentChildItemview extends LinearLayout {
    @BindView(R.id.dzBT)
    TextView dzBT;
    @BindView(R.id.nameTV)
    TextView nameTV;
    @BindView(R.id.contentTV)
    TextView contentTV;
    @BindView(R.id.dateTV)
    TextView dateTV;
    private Context context;
    private VideoDetailResBean.ChildBody thisItem;
    private SingleVideoActivity thisActivity;

    public SVideoCommentChildItemview(Context context) {
        super(context);
        this.context = context;
        LayoutInflater.from(context).inflate(R.layout.itemview_single_video_comment_child, this);
        ButterKnife.bind(this);
        thisActivity = (SingleVideoActivity) context;
    }

    public void bind(VideoDetailResBean.ChildBody item) {
        this.thisItem = item;
        nameTV.setText(item.getUser_name() + "：");
        contentTV.setText(item.getContent());
        dateTV.setText(item.getCreate_date());
        if (item.isGood()) {
            dzBT.setText("♥已赞"+item.getGood_num());
        } else {
            dzBT.setText("♡点赞"+item.getGood_num());
        }
    }

    @OnClick(R.id.dzBT)
    public void onViewClicked() {
        int curGoodNum = Integer.parseInt(dzBT.getText().toString().replace("♡点赞", "").replace("♥已赞", ""));
        thisActivity.requestChildGood(thisItem.getId(),dzBT,dzBT.getText().toString(),curGoodNum);
    }
}
